<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据类型</title>
    <script>
        function f1(){
            let i = 1;
            console.log(typeof i);
            i = "admin";
            console.log(typeof(i))
            i = true;
            console.log(typeof i)
            i = 'a';
            console.log(typeof i)
        }
        function f2(){
            // 声明变量,没有赋值
            let name;
            console.log(typeof name);
            name = null;
            console.log(typeof name);
            name = undefined;
            console.log(typeof name);
            name = NaN;     // Not a Number
            console.log(typeof name);
            let i = "a";
            i = parseInt(i);
            console.log(i);
        }
        function f3(){
            let obj = new Object();
            console.log(typeof obj)
            let arr = [1,2,3];
            console.log(typeof arr)
            let date = new Date();
            console.log(date);
            console.log(typeof date)
        }
        function f4(){
            // 不带括号,表示将指定函数作为整体赋值给变量
            // 此时变量的类型是一个函数类型
            let i = fn;
            // alert(fn)
            console.log(typeof i);
            // 如果带括号,则表示先执行对应函数,将函数的返回值赋值给对应变量
            // 此时变量的类型是函数返回值的类型
            let name = fn();
            alert(name)
        }
        function fn(){
            return "admin";
        }
    </script>
</head>
<body>
<button onclick="f1()">基本数据类型</button><br>
<button onclick="f2()">非正常数据</button><br>
<button onclick="f3()">复合类型</button><br>
<button onclick="f4()">函数类型</button><br>
</body>
</html>